package club.hicode.daydayup.ftp;

import cn.hutool.core.thread.ThreadUtil;
import com.github.jsonzou.jmockdata.JMockData;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;

/**
 * FTP测试
 *
 * @author Liu Chunfu
 * @date 2018-05-22 下午2:59
 **/
public class FtpTest {
    @Test
    public void test1() {

    }

    @Test
    public void testParellaStream() {
        List<String> list = new ArrayList<>(500);
        for (int i = 0; i < 500; i++) {
            String mock = JMockData.mock(String.class);
            list.add(mock);
        }

        list.parallelStream().forEach(s -> {
            System.out.println(Thread.currentThread().getId() + " " + s);
        });
    }

    @Test
    public void testQueue() throws Exception {
        //
        //ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<>(3);
        //for (int i = 0; i < 3; i++) {
        //    queue.put(i + " ");
        //}
        //
        //List<String> urlList=new ArrayList<>(20);
        //urlList.parallelStream().forEach(s->{
        //    String take = null;
        //    try {
        //        take = queue.take();
        //
        //    } catch (InterruptedException e) {
        //        e.printStackTrace();
        //    }finally {
        //        queue.put(take);
        //    }
        //    System.out.println(take);
        //});

    }
}
